<template>
	<view class="version">
		<view class="login_logo">
			<image class="image" src="../../static/img/logo.png" mode="aspectFit"></image>
			<text style="font-size: 28px;color:#22272B;">环球影投</text>
			<text style="font-size: 10px;color:#22272B;">UNIVERSAL STUDIOS</text>
		</view>
		<view class="box">
			<view class="line" style="margin-top: 10%;">当前版本: {{version}}</view>
			<view class="line">最新版本: {{newversion}}</view>
			<button type="primary" @click="getversion" :disabled="isdisabled">{{value}}</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				version: '',
				newversion: '',
				value: '已是最新版本',
				isdisabled: true
			};
		},
		onLoad() {
			this.getData();
			this.version = plus.runtime.version;
		},
		methods: {
			getData: function(type) {
				const _this = this;
				//获取用户信息
				this.$request.get("/api/system/getVersion", {})
					.then(res => {
						if (res.data.code == 1) {
							_this.newversion = res.data.data.version;
							if (_this.newversion !== _this.version) {
								_this.isdisabled = false;
								_this.value = '更新版本'
							}
						}
					})
					.catch(error => {
						console.error('error:', error);
					});
			},
			getversion: function() {
				//打开外部网站
				plus.runtime.openURL('http://www.huanqiuyt.com/web/#/download');
			}
		}
	}
</script>

<style lang="less">
	.version {
		width: 100%;
		display: flex;
		flex-direction: column;
		align-items: center;
		border-top: 5px solid #F1F1F1;

		.login_logo {
			height: 40%;
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;

			.image {
				width: 300upx;
				height: 200upx;
			}
		}

		.box {
			.line {
				font-size: 16px;
				color: #444444;
				line-height: 50px;
				border-bottom: 1px solid rgba(112, 112, 112, 0.13);
			}

			button {
				margin-top: 20px;
			}
		}
	}
</style>
